Repository navigation
fleet-proxy(http): no-body responses (HEAD/204/304) and 1xx handling (#5921) - #5922
Conversation
…5921) HttpConn::request decided the response body solely from the framing headers: a HEAD, 204, or 304 response carrying a Content-Length was read as if body bytes followed (stalling until the 660s tunnel read timeout and killing the pooled connection), and a 1xx interim response was returned as the final answer, leaving the real response in the stream to desync the next pooled exchange. Body existence is now decided from the request method and status class before the framing headers (RFC 9112 section 6.3): HEAD responses and 101/204/304 are body-less regardless of Content-Length or Transfer-Encoding, and 1xx interim responses (except 101) are consumed while the reader continues to the final response. The status/header parse moves into read_response_head so each head in a 1xx sequence gets the same #5579 strict Content-Length validation, which is unchanged for responses that do carry bodies. Pinning canned-peer tests cover HEAD with CL, 204 with CL, 304 with the cached CL, 204 with chunked Transfer-Encoding, and a 103-then-200 sequence, each followed by a clean second exchange on the pooled connection. cargo test -p fleet-proxy --lib: 32 passed. Queue task 9819.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 25 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 56b855b74b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // timeout and kill the connection; skipping them leaves | ||
| // the stream exactly at the next response, so a keep-alive | ||
| // exchange stays reusable. | ||
| let no_body = method.eq_ignore_ascii_case("HEAD") || matches!(status, 101 | 204 | 304); |
There was a problem hiding this comment.
Match the HEAD method case-sensitively
For a request whose method is head or Head, this skips a response body even though HTTP methods are case-sensitive and the request method is transmitted unchanged. These tokens pass parse_request; for example, the queue broker's non-POST branch (queue_broker.rs:644–645) returns a 405 with a JSON body. That body now remains unread while Broker::do_request returns the connection to the pool, causing an empty-body JSON error for this request and desynchronizing the next exchange. Use method == "HEAD" so only an actual HEAD request suppresses body reads.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in f2b83b6 — thank you. The comparison is now method == "HEAD" exactly (HTTP methods are case-sensitive; only an actual HEAD suppresses the body read), with the reason recorded in the comment at the site. Pinned by the new canned-peer test lowercase_head_is_a_different_method_and_reads_its_body: a lowercase head response carrying a Content-Length body is read in full and the connection stays reusable. cargo test -p fleet-proxy --lib: 33 passed.
Codex review finding on PR #5922: HTTP methods are case-sensitive, so eq_ignore_ascii_case("HEAD") would also suppress the body read for a lowercase head request — a different method whose response does carry a body, which would then desync the pooled connection. Compare method == "HEAD" exactly, and pin it with a canned-peer test: a lowercase head response with a Content-Length body is read in full and the connection stays reusable. cargo test -p fleet-proxy --lib: 33 passed.
Fixes #5921 · queue task 9819
What
HttpConn::requestinpkgs/fleet/crates/fleet-proxy/src/http.rsdecided the response body solely from the framing headers, never from the request method or the status class:Content-Lengthbytes that by definition never arrive — stalling the exchange until the 660 s tunnel read timeout, killing the pooled connection, and repeating on the broker's fresh-tunnel retry. A 304 may legitimately carry the Content-Length of the cached 200, so this is not a malformed-peer case.Change
read_response_head, so every head in a 1xx sequence gets the same strict Content-Length validation as before — the fleet-proxy(http): response reader trusts peer-declared sizes (unbounded preallocation) and silently drops the body on a malformed Content-Length, desyncing the pooled connection #5579 malformed / conflicting / oversize behaviour is unchanged for responses that do carry bodies.Tests
Reproduced first: pre-fix, the new 103→200 pinning test failed with the interim status returned as final (
left: 103, right: 200); the no-body shapes hang pre-fix, as the laptop probe in #5921 documented.New canned-peer tests in
http.rs: HEAD with CL, 204 with CL, 304 with the cached CL, 204 with chunked Transfer-Encoding, and a 103→200 sequence — each followed by a clean second exchange on the same pooled connection, plus the ordinary 200 control still passing.cargo test -p fleet-proxy --lib— 33 passed, 0 failedcargo fmt -p fleet-proxy -- --check— clean